package org.goldenport.g3

/**
 * @since   Sep. 11, 2010
 * @version Jan.  2, 2011
 * @author  ASAMI, Tomoharu
 */
package object messages {
  // XXX time
  // XXX timezone

  // json
  @Deprecated
  def seq2json(seq: Seq[(Symbol, Any)]): String = {
    seq.map {
      case (key, value) => "\"" + key.name + "\": " + jsonString(value)
    }.mkString("{", ", ", "}")
  }

  @Deprecated
  def jsonString(value: Any): String = {
    value match {
      case v: Number => v.toString
      case rs: Seq[_] => rs.map {
        case r: Record => r.toJson
        case v => jsonString(v) // TODO optimize
      }.mkString("[", ", ", "]")
/*
      case rs: Seq[Record] => {
        for (rrr <- rs) yield {
          println("rrr = " + rrr.getClass)
          rrr.toJson
        }
      }.mkString("[", "%, ", "]")
*/
      case v => '"' + v.toString + '"'
    }
  }
}
